package com.leanyuan.publi.dao;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.leanyuan.publi.domain.Building;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author 相亲相爱一家人
 * @since 2021-05-25
 */
public interface BuildingMapper extends BaseMapper<Building> {
    @Results(id="Base",value = {
            @Result(id=true,column = "building_id",property="buildingId" ),
            @Result(property = "admin.username",column = "aname")
    })
    @Select({"<script> " +"select b.*,a.name as'aname' from building b  INNER join t_admin a on b.admin_id=a.admin_id where 1=1 and b.delete2='0' " +
            "<if test='id!=null'> and building_id=#{id}</if>" +
            "<if test='name!=null'> and b.name like '%${name}%'</if>"+
            "</script>"})
    List<Building> findAll(Page<Building> page, @Param("id") Integer id,@Param("name") String name);
}
